<extend name="common:base" />
<block name="content">
    <div id="header">
        <div class="header">
            <h1 class="tit">{$site_title}</h1>
            <!--<p class="goback">-->
                <!--<a class="return" href="{:U('Setting/agent_ranks' ,array('id' =>$_GET['b_id']))}">返回</a>-->
            <!--</p>-->
            <!--<p class="more"><a class="share" href=""></a></p>-->
        </div>
    </div>
    <div class="banx-a">
        <div class="a-1">{$rank['welfare']}</div>
        <if condition="$upgrade eq 2">
            <textarea class="remark" name="remark" placeholder="请填写您的想法..."></textarea>
        </if>
        <div id="to_this_rank">
            <if condition="$upgrade eq 2">
                <button class="ipt-ty upgrade" type="button">我要成为此代理</button>
                <elseif condition="$upgrade eq 1"/>
                    <button class="ipt-gray" type="button" disabled>已有申请等待审核</button>
                <else/>
                <button class="ipt-gray" type="button" disabled>级别不符</button>
            </if>
        </div>
    </div>
</block>
<block name="CSS">
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/agreement.css" />
</block>
<block name="JS">
    <script type="text/javascript">
        $(function(){
            $(".upgrade").click(function(){
                var rm = $.trim($(".remark").val());
                if(!rm){
                    layer.alert("请填写备注");
                    return false;
                }
                $.ajax({
                    url: "{:U('Setting/upgrade')}",
                    type: "post",
                    data: {id: "{$rank['rank_id']}",remark:rm ,b_id: "{$b_id}"},
                    success: function (data) {
                        if (data) {
                            if(data.status == "success"){
                                layer.confirm('已提交您的请求', {
                                    btn: ['确定'] //按钮
                                }, function(){
                                    window.location.href = "{:U('Setting/agent_ranks' ,array('id' =>$_GET['b_id']))}";
                                });
                            }else{
                                layer.alert(data.msg);
                            }
                        }
                    }
                });

            });
        });
    </script>
</block>